package com.mofang.ticketing.common.core.enums.base;

import com.mofang.ticketing.common.core.enums.EnumVO;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * 禁用启用枚举
 *
 * @author LGC
 */
@Getter
@AllArgsConstructor
public enum SysEnableEnum {
    /**
     * 禁用启用枚举
     */
    ENABLE(1, "启用"),
    DISABLE(0, "禁用"),
    ;
    private final Integer key;
    private final String value;

    public static String getValueByKey(int key) {
        Optional<SysEnableEnum> optional = Arrays.stream(SysEnableEnum.values())
                .filter(v -> v.getKey() == key).findAny();
        return optional.map(SysEnableEnum::getValue).orElse(null);
    }

    public static List<EnumVO> getKeyValueList() {
        return Arrays.stream(SysEnableEnum.values()).map(s ->
                new EnumVO(s.getKey(), s.getValue())).collect(Collectors.toList());
    }


}
